F-ing applicative functors

نویسندگان

  • Andreas Rossberg
  • Claudio Russo
  • Derek Dreyer
چکیده

Essential to ML-style module systems is the concept of a functor, i.e. a function from modules to modules. Functors are ML’s way of providing generic data structures and reusable program components. Yet, there is a bewildering schism in ML land regarding the actual semantics of functors, familiar to experts under the code words generative vs. applicative. In Standard ML [3], each application of a given functor ‘generates’ fresh copies of all the abstract types the functor defines. For example, two applications Set(Int) of a functor defining an abstract set type will produce two distinct and incompatible instances of this type. For OCaml on the other hand, Leroy [2] suggested a semantics where every application of the same functor to the same argument (under certain syntactic restrictions) reproduces the same type. Consequently, every application Set(Int) would result in the same set type. That is, the functor is ‘applicative’, in the sense that it behaves purely functionally. Applicative functor semantics is more flexible in handling certain modularity scenarios, such as “diamond import” dependencies, where the same functor is used along different paths, without creating type incompatibilities. But it also is far more intricate:

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Constructing Applicative Functors

Applicative functors define an interface to computation that is more general, and correspondingly weaker, than that of monads. First used in parser libraries, they are now seeing a wide range of applications. This paper sets out to explore the space of non-monadic applicative functors useful in programming. We work with a generalization, lax monoidal functors, and consider several methods of co...

متن کامل

Free Applicative Functors

Applicative functors [6] are a generalisation of monads. Both allow the expression of effectful computations into an otherwise pure language, like Haskell [5]. Applicative functors are to be preferred to monads when the structure of a computation is fixed a priori. That makes it possible to perform certain kinds of static analysis on applicative values. We define a notion of free applicative fu...

متن کامل

Applicative Lifting

Applicative functors augment computations with effects by lifting function application to types which model the effects [5]. As the structure of the computation cannot depend on the effects, applicative expressions can be analysed statically. This allows us to lift universally quantified equations to the effectful types, as observed by Hinze [3]. Thus, equational reasoning over effectful comput...

متن کامل

Higher-order modules in System Fω and Haskell

To argue that it is practical to extend core Haskell to support higher-order modules, we translate Dreyer, Crary, and Harper’s higher-order module system (2002, 2003) into System Fω. Our translation is the first to fully treat generative functors (with existential types) alongside applicative ones (with Skolemized types). Applicative functors correspond to higher-order polymorphism in idiomatic...

متن کامل

Equational Reasoning with Applicative Functors

In reasoning about effectful computations, it often suffices to focus on the effect-free parts. We present a package for automatically lifting equations to effects modelled by applicative functors. It exploits properties of the concrete functor thanks to a modular classification based on combinators. We formalise the meta theory and demonstrate the usability of our Isabelle/HOL package with two...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2012